package com.xiguaji.boot.exception;


import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(value = {RuntimeException.class, Exception.class})
    @ResponseBody
    public Map<String, String> handle(Exception e) {
        log.error(e.getMessage(), e);
        throw new RuntimeException("system error");
    }

}